//
//  LBButton.m
//  LBUIKit
//
//  Created by WuShiHai on 19/5/24.
//  Copyright (c) 2019 Lebbay. All rights reserved.
//

#import "LBButton.h"
#import <LBFoundation/LBFoundation.h>

@interface LBButton()

@property (nonatomic, copy) LBButtonActionBlock action;

@end

@implementation LBButton

- (void)dealloc {
    
}

- (void)addAction:(LBButtonActionBlock)action {
    _action = action;
    [self removeTarget:self
                action:@selector(buttonDidClick)
      forControlEvents:UIControlEventTouchUpInside];
    [self addTarget:self
             action:@selector(buttonDidClick)
   forControlEvents:UIControlEventTouchUpInside];
}

- (void)buttonDidClick {
    LBBlockSafeRun(self.action);
}

@end
